import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:interrogation/app/routes/app_pages.dart';
import 'package:interrogation/src/main_service.dart';


void main() {
  WidgetsFlutterBinding.ensureInitialized();
  Get.put(MainService());
  // 设置为透明
  SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(statusBarColor: Colors.transparent));
  runApp(const MyApp(
    key: Key("app"),
  ));
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  ///app 全局context
  static final GlobalKey<NavigatorState> navigatorKey =
      GlobalKey<NavigatorState>();

  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
        designSize: const Size(375, 812),
        minTextAdapt: true,
        splitScreenMode: true,
        builder: (BuildContext context, Widget? widget) => GetMaterialApp(
              getPages: AppPages.routes,
              debugShowCheckedModeBanner: false,
              title: "智能问诊",
              initialRoute: AppPages.INITIAL,
              defaultTransition: Transition.rightToLeft,
              builder: (context, widget) {
                return MediaQuery(
                  //设置文字大小不随系统设置改变
                  data: MediaQuery.of(context).copyWith(
                    textScaler: TextScaler.linear(1.0),
                  ),
                  child: FlutterEasyLoading(
                    child: widget,
                  ),
                );
              },
          theme: ThemeData(
            appBarTheme: const AppBarTheme(
              /// ...
              /// 设置AppBar 的表面颜色为透明色
              surfaceTintColor: Colors.transparent,
              /// ...
            ),
          ),
              navigatorKey: navigatorKey,
              unknownRoute: AppPages.UNKNOW,
              transitionDuration: const Duration(milliseconds: 300),
              // theme: lightTheme,
              // darkTheme: darkTheme,
              themeMode: ThemeMode.light,
              // initialBinding:
              // GlobalInfo.isHasToken() ? MainTabBinding() : LoginBinding(),
              //   home: GlobalInfo.isHasToken() ? MainTabPage() : LoginPage(),
            ));
  }
}
